using System;
using System.Text.RegularExpressions;

namespace resharperupdate.core.services.impl
{
    public class ProductVersionParser : IProductVersionParser
    {
        public int build(string product_version)
        {
            if (!Regex.IsMatch(product_version, "\\d[.]\\d[.]\\d+[.]\\d+"))
                throw new DataMisalignedException("the product version is in an unexpected format");
            return Convert.ToInt32(product_version.Split('.')[2]);
        }
    }
}